/*
 * Copyright (c) 2010, Nikolaus Moll
 * All rights reserved.
 */
package net.gradecalculator.plugin.core.srdx.internal;

import java.util.LinkedList;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

@XmlRootElement(namespace = "http://gradecalculator.net/", name = "selectableModuleLists")
@XmlType( 
 name = "selectableModuleLists",
 propOrder = { "name",  "moduleListECTS", "pickCount", "moduleLists" } 
) 
public class XmlSelectableModuleLists implements IXmlModuleListItem, IXmlModuleIdentificator {
	private List<XmlModuleList> moduleLists = new LinkedList<XmlModuleList>();
	private String name;
	private int pickCount;
	private float moduleListECTS;
	
	private IXmlModuleIdentificator parent;
	
	@Override
	@XmlTransient
	public IXmlModuleIdentificator getParent()
	{
		return parent;
	}
	@Override
	public void setParent(final IXmlModuleIdentificator parent)
	{
		this.parent = parent;
	}
	
	
	@Override
	@XmlElement(name = "name" )
	public String getName() {
		return name;
	}
	public void setName(final String name) {
		this.name = name;
	}

	@XmlElement(name = "pickcount" )
	public int getPickCount() {
		return pickCount;
	}
	public void setPickCount(final int pickCount) {
		this.pickCount = pickCount;
	}

	@XmlElement(name = "ects" )
	public float getModuleListECTS() {
		return moduleListECTS;
	}
	public void setModuleListECTS(final float ects) {
		this.moduleListECTS = ects;
	}
	
	@XmlElementWrapper(name = "modulelists")
	@XmlElement(name = "modulelist" )
	public List<XmlModuleList> getModuleLists()
	{
		return moduleLists;
	}

	@Override
	public String getIdentifier() {
		if (parent != null) {
			return parent.getIdentifier() + "." + name;
		}
		return name;
	}
}
